package com.creditease.shield.flow.boot;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.boot.autoconfigure.web.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.HttpMessageConverter;

/**
 * 让springmvc，不使用转换jackson，儿使用fastjson，
 * @author weiliu119
 *
 */
//@Configuration
public class JsonConvert {
	/**
     * 使用bean注入,才能使其有效果,验证的话就在Entity字段中使用fastjson的
     * 注解@JSONField(serialize = false),转换出来的信息不含该字段,则成功
     * @return
     */
    @Bean
    public HttpMessageConverters customConverters() {
        FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
        fastConverter.setFeatures(SerializerFeature.PrettyFormat); 
        return new HttpMessageConverters((HttpMessageConverter<?>) fastConverter);
    }
}
